package com.woniuxy.propertyjava.service.impl;

import com.woniuxy.propertyjava.dao.Holdinformation1Dao;
import com.woniuxy.propertyjava.entity.Holdinformation1;
import com.woniuxy.propertyjava.entity.PageBean;
import com.woniuxy.propertyjava.service.Holdinformation1Service;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * (Holdinformation1)表服务实现类
 *
 * @author makejava
 * @since 2022-07-06 09:59:26
 */
@Service("holdinformation1Service")
public class Holdinformation1ServiceImpl implements Holdinformation1Service {
    @Resource
    private Holdinformation1Dao holdinformation1Dao;

    /**
     * 通过ID查询单条数据
     *
     * @param hhid 主键
     * @return 实例对象
     */
    @Override
    public Holdinformation1 queryById(Integer hhid) {
        return this.holdinformation1Dao.queryById(hhid);
    }

    /**
     * 分页查询
     *
     * @param holdinformation1 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @Override
    public PageBean<Holdinformation1> queryByPage(Holdinformation1 holdinformation1, int pageIndex,int pageSize) {
        long total = this.holdinformation1Dao.count(holdinformation1);
        PageBean<Holdinformation1> pageBean = new PageBean<>();
        pageBean.setBeanList(holdinformation1Dao.queryAllByLimit(holdinformation1,pageIndex,pageSize));
        pageBean.setPageIndex(pageIndex);
        pageBean.setPageSize(pageSize);
        pageBean.setTotalRecode((int)total);
        return pageBean;
    }

    /**
     * 新增数据
     *
     * @param holdinformation1 实例对象
     * @return 实例对象
     */
    @Override
    public Holdinformation1 insert(Holdinformation1 holdinformation1) {
        this.holdinformation1Dao.insert(holdinformation1);
        return holdinformation1;
    }

    /**
     * 修改数据
     *
     * @param holdinformation1 实例对象
     * @return 实例对象
     */
    @Override
    public Holdinformation1 update(Holdinformation1 holdinformation1) {
        this.holdinformation1Dao.update(holdinformation1);
        return this.queryById(holdinformation1.getHhid());
    }

    /**
     * 通过主键删除数据
     *
     * @param hhid 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer hhid) {
        return this.holdinformation1Dao.deleteById(hhid) > 0;
    }
}
